home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / LISTBOX / FILE32 / LONGNAME.PAS < prev    next >
Pascal/Delphi Source File  |  1995-06-27  |  8KB  |  210 lines

  1. unit longname;
  2. {Functions to use long filenames}
  3. {All functions start with "W32" to distinguish them from 16 bit functions}
  4. {To call a function, use it like a normal function, with one exception:
  5.  the last parameter must be the id value for that function. Example:
  6.  longhandle:=W32FindFirstFile('c:\*.*',finddata,id_W32FindFirstFile);}
  7.  
  8. {VERY IMPORTANT: All these functions work fine on Windows 95, but NOT all work on
  9.  Windows NT:
  10.  - W32SetCurrentDirectory returns true, but does NOT actually change the current directory
  11.  
  12.  all other functions seem to work fine, but test your application on NT before saying that
  13.  it runs fine!
  14. }
  15.  
  16. interface
  17.  
  18. uses call32nt;
  19.  
  20. type
  21.   longfile=longint;
  22.  
  23. {WIN32_FIND_DATA structure:}
  24. type
  25.   WIN32_FIND_DATA=record
  26.     dwFileAttributes:longint;
  27.     ftCreationTime,
  28.     ftLastAccessTime,
  29.     ftLastWriteTime:array[0..1] of longint;
  30.     nFileSizeHigh,
  31.     nFileSizeLow,
  32.     dwReserved0,
  33.     dwReserved1:longint;
  34.     cFileName:array[0..259] of char;
  35.     cAlternateFileName:array[0..13] of char;
  36.   end;
  37.   pWIN32_FIND_DATA=^WIN32_FIND_DATA;
  38.  
  39. type
  40.   tFILETIME=record
  41.     dwLowDateTime,
  42.     dwHighDateTime:longint;
  43.   end;
  44.   pFILETIME=^tFILETIME;
  45.  
  46.   tSYSTEMTIME=record
  47.     Year,
  48.     Month,
  49.     DayOfWeek,
  50.     Day,
  51.     Hour,
  52.     Min,
  53.     Sec,
  54.     Milliseconds:word;
  55.   end;
  56.  
  57.   tStartupInfo=record
  58.     cb:longint;
  59.     lpReserved,
  60.     lpDesktop,
  61.     lpTitle:pchar;
  62.     dwX,
  63.     dwY,
  64.     dwXSize,
  65.     dwYSize,
  66.     dwXCountChars,
  67.     dwYCountChars,
  68.     dwFillAttribute,
  69.     dwFlags:longint;
  70.     wShowWindow,
  71.     cbReserved2:word;
  72.     lpReserved2:^byte;
  73.     hStdInput,
  74.     hStdOutput,
  75.     hStdError:longint;
  76.   end;
  77.  
  78.   PROCESS_INFORMATION=record
  79.     hProcess,
  80.     hThread,
  81.     dwProcessId,
  82.     dwThreadId:longint;
  83.   end;
  84.  
  85. var
  86.   W32FindFirstFile:function(lpszSearchFile:pchar;var lpffd:WIN32_FIND_DATA;id:longint):longint;
  87.   W32FindNextFile:function(hFindFile:longint;var lpffd:WIN32_FIND_DATA;id:longint):longbool;
  88.   W32FindClose:function(hFindFile:longint;id:longint):Longbool;
  89.   W32FileTimeToSystemTime:function(var lpft:tFILETIME;var lpst:tsystemtime;id:longint):longbool;
  90.   W32FileTimeToLocalFileTime:function(var lpft,lpftlocal:tFILETIME;id:longint):longbool;
  91.   W32SystemTimeToFileTime:function(var lpst:tsystemtime;var lpft:tFILETIME;id:longint):longbool;
  92.   W32LocalFileTimeToFileTime:function(var lpftlocal,lpft:tFILETIME;id:longint):longbool;
  93.   W32GetCurrentDirectory:function(cchCurDir:longint;lpszCurDir:pchar;id:longint):longint;
  94.   W32SetCurrentDirectory:function(lpszCurDir:pchar;id:longint):longbool;
  95.   W32CreateFile:function(lpszName:pchar;fdwAccess,fdwShareMode:longint;lpsa:pointer;
  96.                          fdwCreate,fdwAttrsAndFlags,hTemplateFile,id:longint):longint;
  97.   W32MoveFile:function(lpszExisting,lpszNew:pchar;id:longint):longbool;
  98.   W32GetLastError:function(id:longint):longint;
  99.   W32CreateDirectory:function(path:pchar;security:pointer;id:longint):longbool;
  100.   W32RemoveDirectory:function(path:pchar;id:longint):longbool;
  101.   W32SetFileAttributes:function(path:pchar;attr,id:longint):longbool;
  102.   W32GetFileAttributes:function(path:pchar;id:longint):longint;
  103.   W32Deletefile:function(path:pchar;id:longint):longbool;
  104.   W32SetFilePointer:function(hFile,lDistanceToMove:longint;lpDistanceToMoveHigh:pointer;
  105.             dwMoveMethod,id:longint):longint;
  106.   W32SetFileTime:function(hFile:longint;lpftCreation,lpftLastAccess,lpftLastWrite:pfiletime;
  107.             id:longint):longbool;
  108.   W32GetFileTime:function(hFile:longint;lpftCreation,lpftLastAccess,lpftLastWrite:pfiletime;
  109.             id:longint):longbool;
  110.   W32CloseHandle:function(hfile,id:longint):longbool;
  111.   W32ReadFile:function(hFile:longint;var lpBuffer;nNumberOfBytesToRead:longint;
  112.     var lpNumberOfBytesRead:longint;lpOverlapped:pointer;id:longint):longbool;
  113.   W32WriteFile:function(hFile:longint;var lpBuffer;nNumberOfBytesToWrite:longint;
  114.     var lpNumberOfBytesWritten:longint;lpOverlapped:pointer;id:longint):longbool;
  115.   W32FlushFileBuffers:function(hfile,id:longint):longbool;
  116.   W32ShellExecute:function(hwnd:longint;lpszOp,lpszFile,lpszParams,lpszDir:pchar;wShowCmd,id:longint):longint;
  117.   W32WaitForSingleObject:function(hObject,dwTimeout,id:longint):longint;
  118.   W32CreateProcess:function(lpszImageName,lpszCommandLine:pchar;lpsaProcess,lpsaThread:pointer;
  119.     fInheritHandles:longbool;fdwCreate:longint;lpvEnvironment:pointer;lpszCurDir:pchar;var lpsiStartInfo:tstartupinfo;
  120.     var lppiProcInfo:PROCESS_INFORMATION;id:longint):longbool;
  121.  
  122. var
  123.   id_W32FindFirstFile,
  124.   id_W32FindNextFile,
  125.   id_W32FindClose,
  126.   id_W32FileTimeToSystemTime,
  127.   id_W32FileTimeToLocalFileTime,
  128.   id_W32SystemTimeToFileTime,
  129.   id_W32LocalFileTimeToFileTime,
  130.   id_W32GetCurrentDirectory,
  131.   id_W32SetCurrentDirectory,
  132.   id_W32CreateFile,
  133.   id_W32MoveFile,
  134.   id_W32GetLastError,
  135.   id_W32CreateDirectory,
  136.   id_W32RemoveDirectory,
  137.   id_W32SetFileAttributes,
  138.   id_W32GetFileAttributes,
  139.   id_W32Deletefile,
  140.   id_W32SetFilePointer,
  141.   id_W32setFileTime,
  142.   id_W32GetFileTime,
  143.   id_W32CloseHandle,
  144.   id_W32ReadFile,
  145.   id_W32WriteFile,
  146.   id_W32FlushFileBuffers,
  147.   id_W32ShellExecute,
  148.   id_W32WaitForSingleObject,
  149.   id_W32CreateProcess:longint;
  150.  
  151. implementation
  152.  
  153. begin
  154.   @W32FindFirstFile:=@Call32;
  155.   @W32FindNextFile:=@Call32;
  156.   @W32FindClose:=@Call32;
  157.   @W32FileTimeToSystemTime:=@Call32;
  158.   @W32FileTimeToLocalFileTime:=@Call32;
  159.   @W32SystemTimeToFileTime:=@Call32;
  160.   @W32LocalFileTimeToFileTime:=@Call32;
  161.   @W32GetCurrentDirectory:=@Call32;
  162.   @W32SetCurrentDirectory:=@Call32;
  163.   @W32CreateFile:=@Call32;
  164.   @W32MoveFile:=@Call32;
  165.   @W32GetLastError:=@Call32;
  166.   @W32CreateDirectory:=@Call32;
  167.   @W32RemoveDirectory:=@Call32;
  168.   @W32SetFileAttributes:=@Call32;
  169.   @W32GetFileAttributes:=@Call32;
  170.   @W32Deletefile:=@Call32;
  171.   @W32SetFilePointer:=@Call32;
  172.   @W32setFileTime:=@Call32;
  173.   @W32GetFileTime:=@Call32;
  174.   @W32CloseHandle:=@Call32;
  175.   @W32ReadFile:=@Call32;
  176.   @W32WriteFile:=@Call32;
  177.   @W32FlushFileBuffers:=@Call32;
  178.   @W32ShellExecute:=@Call32;
  179.   @W32WaitForSingleObject:=@Call32;
  180.   @W32CreateProcess:=@Call32;
  181.  
  182.   id_W32FindFirstFile:=Declare32('FindFirstFile', 'kernel32', 'pp');
  183.   id_W32FindNextFile:=Declare32('FindNextFile', 'kernel32', 'ip');
  184.   id_W32FindClose:=Declare32('FindClose', 'kernel32', 'i');
  185.   id_W32FileTimeToSystemTime:=Declare32('FileTimeToSystemTime', 'kernel32', 'pp');
  186.   id_W32FileTimeToLocalFileTime:=Declare32('FileTimeToLocalFileTime', 'kernel32', 'pp');
  187.   id_W32SystemTimeToFileTime:=Declare32('SystemTimeToFileTime','kernel32','pp');
  188.   id_W32LocalFileTimeToFileTime:=Declare32('LocalFileTimeToFileTime','kernel32','pp');
  189.   id_W32GetCurrentDirectory:=Declare32('GetCurrentDirectory','kernel32','ip');
  190.   id_W32SetCurrentDirectory:=Declare32('SetCurrentDirectory','kernel32','p');
  191.   id_W32CreateFile:=Declare32('CreateFile','kernel32','piipiii');
  192.   id_W32MoveFile:=Declare32('MoveFile','kernel32','pp');
  193.   id_W32GetLastError:=Declare32('GetLastError','kernel32','');
  194.   id_W32CreateDirectory:=Declare32('CreateDirectory','kernel32','pp');
  195.   id_W32RemoveDirectory:=Declare32('RemoveDirectory','kernel32','p');
  196.   id_W32SetFileAttributes:=Declare32('SetFileAttributes','kernel32','pi');
  197.   id_W32GetFileAttributes:=Declare32('GetFileAttributes','kernel32','p');
  198.   id_W32Deletefile:=Declare32('DeleteFile','kernel32','p');
  199.   id_W32SetFilePointer:=Declare32('SetFilePointer','kernel32','iipi');
  200.   id_W32setFileTime:=Declare32('SetFileTime','kernel32','ippp');
  201.   id_W32GetFileTime:=Declare32('GetFileTime','kernel32','ippp');
  202.   id_W32CloseHandle:=Declare32('CloseHandle','kernel32','i');
  203.   id_W32ReadFile:=Declare32('ReadFile','kernel32','ipipp');
  204.   id_W32WriteFile:=Declare32('WriteFile','kernel32','ipipp');
  205.   id_W32FlushFileBuffers:=Declare32('FlushFileBuffers','kernel32','i');
  206.   id_W32ShellExecute:=Declare32('ShellExecute','shell32','wppppi');
  207.   id_W32WaitForSingleObject:=Declare32('WaitForSingleObject','kernel32','ii');
  208.   id_W32CreateProcess:=Declare32('CreateProcess','kernel32','ppppiipppp');
  209. end.
  210.